package com.jiazhong.springmvc.test01;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther:shuXin
 */
@Controller
@RequestMapping("user")
public class MvcController {
    /*
    RequestMapping:向handlerMapper中定义的方法
    ResponseBody：传递的参数，返回的数据，将数据返回给前端，返回的是字符串
    精确访问 user/hello
    模糊访问 user/* user/**
    作用在类和方法上的区别
    设置方法的请求模式 method = RequestMethod.GET
     */
    @RequestMapping(value = "hello",method = RequestMethod.POST)
    @ResponseBody
    public String hello() {
        System.out.println("hello world");
        return "hello world SpringMVC";
    }


    @RequestMapping(value = "register")
    @ResponseBody
    public String register(){
        System.out.println("register");
        return "zhu ce chen gong";
    }

    @GetMapping("zhangsan")
    @ResponseBody
    public String getInfo(){
        System.out.println("getInfo");
        return "zhangsan";
    }
}
